#pragma once

#include "Utility\Matrix.h"
#include "Utility\FixedArray.h"
#include "Utility\Map.h"
#include "ColladaFile.h"


class ColladaGeometry
{
public:
	ColladaGeometry();
	~ColladaGeometry(void);

	void					SetBoneCount(int i);
	void					SetVertCount(int i);
	void					SetIndexCount(int i);
	void					SetName(const char* pszName);

	u32						GetHash()				{ return m_uHash; }
	const char*				GetName()				{ return m_pszName; }
	int						GetVertexCount()		{ return m_iVertexCount; }
	int						GetIndexCount()			{ return m_iIndexCount; }
	int						GetBoneCount()			{ return m_iBoneCount; }
	Vector4					GetPosition(int i)		{ return m_aPositions[i]; }
	Vector4					GetNormal(int i)		{ return m_aNormals[i]; }
	int						GetIndex(int i)			{ return m_aIndices[i];	}
	Vector4					GetUV(int i)			{ return m_aUVs[i];		}
	Vector4					GetBlendWeights(int i)	{ return m_aBlendWeights[i]; }
	u32						GetBlendIndices(int i)	{ return m_aBlendIndices[i]; }
	FixedArray<Vector4>*	GetPositions()			{ return &m_aPositions; }
	FixedArray<u16>&		GetIndices()			{ return m_aIndices; }
	char*					GetTextureFile()		{ return m_pszTexture; }

	void					SetTextureFile(char* szTexture)	{ m_pszTexture = szTexture; }
	void					SetPosition(int i, const Vector4& v)	{ m_aPositions[i] = v; }
	void					SetNormal(int i,const Vector4& v)		{ m_aNormals[i] = v; }
	void					SetIndice(int i, u16 iIndex)			{ m_aIndices[i] = iIndex;	}
	void					SetUV(int i,const Vector4& v)			{ m_aUVs[i] = v;		}
	void					SetBlendWeights(int i,const Vector4& v)	{ m_aBlendWeights[i] = v; }
	void					SetBlendIndices(int i, u32 uIndices)	{ m_aBlendIndices[i] = uIndices; }
	
protected:
	char*					m_pszTexture;
	char*					m_pszName;
	u32						m_uHash;
	FixedArray<u16>			m_aIndices;
	FixedArray<Vector4>	    m_aPositions;
	FixedArray<Vector4>		m_aNormals;
	FixedArray<Vector4>		m_aUVs;
	int						m_iVertexCount;
	int						m_iIndexCount;
	int						m_iBoneCount;
	

	FixedArray<Vector4>					m_aBlendWeights;
	FixedArray<u32>						m_aBlendIndices;
};

inline ColladaGeometry::ColladaGeometry()
	//m_aBlendIndices(), m_aBlendWeights(), m_aIndices(), m_aNormals(), m_aPositions(), m_aUVs()
{
	m_iBoneCount = 0;
	m_pszTexture = 0;

}

inline ColladaGeometry::~ColladaGeometry(void)
{
	free(m_pszName);

	if( m_pszTexture )
		delete[] m_pszTexture;
}

inline void ColladaGeometry::SetBoneCount(int i)
{
	m_iBoneCount = i;
}

inline void ColladaGeometry::SetVertCount(int i)
{
	m_iVertexCount = i;

	m_aPositions.SetSize(i);
	m_aNormals.SetSize(i);
	m_aUVs.SetSize(i);
	m_aBlendWeights.SetSize(i);
	m_aBlendIndices.SetSize(i);
}

inline void ColladaGeometry::SetIndexCount(int i)
{
	m_iIndexCount = i;
	m_aIndices.SetSize(i);
}

inline void ColladaGeometry::SetName(const char *pszName)
{
	m_pszName = _strdup(pszName);
	m_uHash = StringHash(pszName);
}